﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.Controls;
using YArchitech.DataModel;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace YArchitech.HVAC
{
	public partial class FrmPipeMark : System.Windows.Forms.Form
	{
		public FrmPipeMark()
		{
			this.InitializeComponent();
			new YJKProcessTools().ShowInTaskbarChange(this);
			this.color = this.ckbType.BackColor;
			//base.Icon = Resource.YArchitechIcon;
			this.pipeTag = new HYTagOperate();
		}

		private void FrmPipeMark_Load(object sender, EventArgs e)
		{
			this.pipeTagDis = Convert.ToDouble(this.pipeTag.GetNodeValue("PipeTag", "pipeTagDis"));
			this.multiplyTagDis = Convert.ToDouble(this.pipeTag.GetNodeValue("PipeTag", "multiplyDis"));
			string nodeValue = this.pipeTag.GetNodeValue("PipeTag", "markContent");
			this.pipeTag.GetNodeValue("PipeTag", "type");
			string nodeValue2 = this.pipeTag.GetNodeValue("PipeTag", "style");
			this.SetMarkStyle(nodeValue);
			if (!(nodeValue2 == "single"))
			{
				if (!(nodeValue2 == "auto"))
				{
					if (!(nodeValue2 == "multiply"))
					{
						this.rbtnSignle.Checked = true;
						this.rbtnAuto.Checked = false;
						this.rbtnMultiply.Checked = false;
						this.txtAutoDis.Enabled = false;
						this.ckbDrawSlash.Enabled = false;
						this.hytbMultiSel.Enabled = false;
						this.hytbMultiSel.ReadOnly = true;
					}
					else
					{
						this.rbtnSignle.Checked = false;
						this.rbtnAuto.Checked = false;
						this.rbtnMultiply.Checked = true;
						this.txtAutoDis.Enabled = false;
						this.ckbDrawSlash.Enabled = true;
						this.radioButtonMiddle.Enabled = false;
						this.ckbMoreSelect.Enabled = true;
						this.hytbMultiSel.Enabled = true;
						this.hytbMultiSel.ReadOnly = false;
					}
				}
				else
				{
					this.rbtnSignle.Checked = false;
					this.rbtnAuto.Checked = true;
					this.rbtnMultiply.Checked = false;
					this.txtAutoDis.Enabled = true;
					this.ckbDrawSlash.Enabled = false;
					this.radioButtonMiddle.Enabled = true;
					this.ckbMoreSelect.Enabled = false;
					this.hytbMultiSel.Enabled = false;
					this.hytbMultiSel.ReadOnly = true;
				}
			}
			else
			{
				this.rbtnSignle.Checked = true;
				this.rbtnAuto.Checked = false;
				this.rbtnMultiply.Checked = false;
				this.txtAutoDis.Enabled = false;
				this.ckbDrawSlash.Enabled = false;
				this.radioButtonMiddle.Enabled = true;
				this.ckbMoreSelect.Enabled = false;
				this.hytbMultiSel.Enabled = false;
				this.hytbMultiSel.ReadOnly = true;
			}
			this.txtAutoDis.Text = this.pipeTag.GetNodeValue("PipeTag", "distance");
			this.markUpMiddleDown = this.pipeTag.GetNodeValue("PipeTag", "markUpMiddleDown");
			this.isMarkMultiDisance = (this.pipeTag.GetNodeValue("PipeTag", "isMarkMultiDisance") == "Yes");
			this.IsDelete = (this.pipeTag.GetNodeValue("PipeTag", "IsDelete") == "Yes");
			this.markMultiDistance = Convert.ToDouble(this.pipeTag.GetNodeValue("PipeTag", "markMultiDistance"));
			this.hytbMultiSel.Text = this.markMultiDistance.ToString();
			if (this.IsDelete)
			{
				this.ckbIsDelete.Checked = true;
			}
			else
			{
				this.ckbIsDelete.Checked = false;
			}
			if (this.isMarkMultiDisance)
			{
				this.ckbMoreSelect.Checked = true;
				this.hytbMultiSel.Enabled = true;
			}
			else
			{
				this.ckbMoreSelect.Checked = false;
				this.hytbMultiSel.Enabled = false;
			}
			string a = this.markUpMiddleDown;
			if (!(a == "上"))
			{
				if (!(a == "中"))
				{
					if (!(a == "下"))
					{
						this.radioButtonUp.Checked = true;
						this.radioButtonMiddle.Checked = false;
						this.radioButtonDown.Checked = false;
					}
					else
					{
						this.radioButtonUp.Checked = false;
						this.radioButtonMiddle.Checked = false;
						this.radioButtonDown.Checked = true;
					}
				}
				else
				{
					this.radioButtonUp.Checked = false;
					this.radioButtonMiddle.Checked = true;
					this.radioButtonDown.Checked = false;
				}
			}
			else
			{
				this.radioButtonUp.Checked = true;
				this.radioButtonMiddle.Checked = false;
				this.radioButtonDown.Checked = false;
			}
			if (this.pipeTag.GetNodeValue("PipeTag", "isSlash") == "Yes")
			{
				this.ckbDrawSlash.Checked = true;
			}
		}

		private void radioCheckedChanged(object sender, EventArgs e)
		{
			if (this.rbtnSignle.Checked)
			{
				this.txtAutoDis.Enabled = false;
				this.ckbDrawSlash.Enabled = false;
				this.ckbDrawSlash.BackColor = this.color;
				this.ckbIsDelete.Enabled = true;
				this.radioButtonMiddle.Enabled = true;
				this.ckbMoreSelect.Enabled = false;
				this.hytbMultiSel.Enabled = false;
				this.hytbMultiSel.ReadOnly = true;
				return;
			}
			if (this.rbtnMultiply.Checked)
			{
				this.txtAutoDis.Enabled = false;
				this.ckbDrawSlash.Enabled = true;
				this.ckbDrawSlash.BackColor = System.Drawing.Color.White;
				this.ckbIsDelete.Enabled = true;
				this.radioButtonMiddle.Enabled = false;
				this.ckbMoreSelect.Enabled = true;
				this.hytbMultiSel.Enabled = true;
				this.hytbMultiSel.ReadOnly = false;
				if (this.radioButtonMiddle.Checked)
				{
					this.radioButtonUp.Checked = true;
					return;
				}
			}
			else if (this.rbtnAuto.Checked)
			{
				this.txtAutoDis.Enabled = true;
				this.ckbDrawSlash.Enabled = false;
				this.ckbDrawSlash.BackColor = this.color;
				this.radioButtonMiddle.Enabled = true;
				this.ckbMoreSelect.Enabled = false;
				this.hytbMultiSel.Enabled = false;
				this.hytbMultiSel.ReadOnly = true;
				this.ckbIsDelete.Checked = true;
				this.ckbIsDelete.Enabled = false;
			}
		}

		private void btnCancle_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private void btnMark_Click(object sender, EventArgs e)
		{
			if (this.rbtnSignle.Checked)
			{
				this.markStyle = "single";
			}
			else if (this.rbtnAuto.Checked)
			{
				this.markStyle = "auto";
			}
			else if (this.rbtnMultiply.Checked)
			{
				this.markStyle = "multiply";
			}
			if (this.ckbMoreSelect.Checked)
			{
				this.isMarkMultiDisance = true;
			}
			else
			{
				this.isMarkMultiDisance = false;
			}
			if (this.ckbIsDelete.Checked)
			{
				this.IsDelete = true;
				this.pipeTag.SetNodeValue("PipeTag", "IsDelete", "Yes");
			}
			else
			{
				this.IsDelete = false;
				this.pipeTag.SetNodeValue("PipeTag", "IsDelete", "No");
			}
			if (this.radioButtonUp.Checked)
			{
				this.markUpMiddleDown = "上";
			}
			else if (this.radioButtonMiddle.Checked)
			{
				this.markUpMiddleDown = "中";
			}
			else if (this.radioButtonDown.Checked)
			{
				this.markUpMiddleDown = "下";
			}
			string a = this.markStyle;
			if (!(a == "auto"))
			{
				if (a == "multiply")
				{
					if (this.ckbDrawSlash.Checked)
					{
						this.isHaveSlash = true;
					}
					else
					{
						this.isHaveSlash = false;
					}
				}
			}
			else
			{
				this.markDistance = Convert.ToDouble(this.txtAutoDis.Text);
			}
			this.markContent = this.GetMarkStyle();
			this.pipeTag.SetNodeValue("PipeTag", "markContent", this.markContent);
			this.pipeTag.SetNodeValue("PipeTag", "distance", this.txtAutoDis.Text);
			if (this.rbtnSignle.Checked)
			{
				this.pipeTag.SetNodeValue("PipeTag", "style", "single");
			}
			else if (this.rbtnAuto.Checked)
			{
				this.pipeTag.SetNodeValue("PipeTag", "style", "auto");
			}
			else if (this.rbtnMultiply.Checked)
			{
				this.pipeTag.SetNodeValue("PipeTag", "style", "multiply");
			}
			if (this.ckbDrawSlash.Checked)
			{
				this.pipeTag.SetNodeValue("PipeTag", "isSlash", "Yes");
			}
			else
			{
				this.pipeTag.SetNodeValue("PipeTag", "isSlash", "No");
			}
			if (this.isMarkMultiDisance)
			{
				this.pipeTag.SetNodeValue("PipeTag", "isMarkMultiDisance", "Yes");
			}
			else
			{
				this.pipeTag.SetNodeValue("PipeTag", "isMarkMultiDisance", "No");
			}
			if (this.radioButtonUp.Checked)
			{
				this.pipeTag.SetNodeValue("PipeTag", "markUpMiddleDown", "上");
			}
			else if (this.radioButtonMiddle.Checked)
			{
				this.pipeTag.SetNodeValue("PipeTag", "markUpMiddleDown", "中");
			}
			else if (this.radioButtonDown.Checked)
			{
				this.pipeTag.SetNodeValue("PipeTag", "markUpMiddleDown", "下");
			}
			if (this.markDistance < 10.0)
			{
				this.markDistance = 500.0;
				this.txtDistance.Text = "500";
			}
			if (this.markMultiDistance < 10.0)
			{
				this.markMultiDistance = 500.0;
				this.hytbMultiSel.Text = "500";
			}
			this.markMultiDistance = Convert.ToDouble(this.hytbMultiSel.Text);
			this.pipeTag.SetNodeValue("PipeTag", "markMultiDistance", this.markMultiDistance.ToString());
			this.pipeTag.SaveXml();
			base.DialogResult = DialogResult.Yes;
		}

		private string GetMarkStyle()
		{
			string result = "";
			bool @checked = this.ckbDiameter.Checked;
			bool checked2 = this.ckbType.Checked;
			bool checked3 = this.ckbOffSet.Checked;
			bool checked4 = this.ckbInsideDia.Checked;
			if (checked2 && !@checked && !checked3 && !checked4)
			{
				result = "style1";
			}
			else if (checked2 && @checked && !checked3)
			{
				result = "style2";
			}
			else if (checked2 && checked4 && !checked3)
			{
				result = "style21";
			}
			else if (checked2 && !@checked && checked3 && !checked4)
			{
				result = "style3";
			}
			else if (checked2 && @checked && checked3)
			{
				result = "style4";
			}
			else if (checked2 && checked4 && checked3)
			{
				result = "style41";
			}
			else if (!checked2 && @checked && !checked3)
			{
				result = "style5";
			}
			else if (!checked2 && checked4 && !checked3)
			{
				result = "style51";
			}
			else if (!checked2 && @checked && checked3)
			{
				result = "style6";
			}
			else if (!checked2 && checked4 && checked3)
			{
				result = "style61";
			}
			else if (!checked2 && !@checked && checked3 && !checked4)
			{
				result = "style7";
			}
			return result;
		}

		private void SetMarkStyle(string markStyle)
		{
			bool @checked = this.ckbDiameter.Checked;
			bool checked2 = this.ckbType.Checked;
			bool checked3 = this.ckbOffSet.Checked;
			bool checked4 = this.ckbInsideDia.Checked;
			uint num = YArchitech.Revit.PrivateImplementationDetails.ComputeStringHash(markStyle);
			if (num > 4032281248u)
			{
				if (num <= 4082614105u)
				{
					if (num != 4049058867u)
					{
						if (num != 4065836486u)
						{
							if (num != 4082614105u)
							{
								return;
							}
							if (!(markStyle == "style5"))
							{
								return;
							}
							this.ckbDiameter.Checked = true;
							this.ckbType.Checked = false;
							this.ckbOffSet.Checked = false;
							this.ckbInsideDia.Checked = false;
							return;
						}
						else
						{
							if (!(markStyle == "style4"))
							{
								return;
							}
							this.ckbDiameter.Checked = true;
							this.ckbType.Checked = true;
							this.ckbOffSet.Checked = true;
							this.ckbInsideDia.Checked = false;
							return;
						}
					}
					else
					{
						if (!(markStyle == "style7"))
						{
							return;
						}
						this.ckbDiameter.Checked = false;
						this.ckbType.Checked = false;
						this.ckbOffSet.Checked = true;
						this.ckbInsideDia.Checked = false;
					}
				}
				else if (num != 4099391724u)
				{
					if (num != 4116169343u)
					{
						if (num == 4149724581u)
						{
							if (!(markStyle == "style1"))
							{
								return;
							}
							this.ckbDiameter.Checked = false;
							this.ckbType.Checked = true;
							this.ckbOffSet.Checked = false;
							this.ckbInsideDia.Checked = false;
							return;
						}
					}
					else
					{
						if (!(markStyle == "style3"))
						{
							return;
						}
						this.ckbDiameter.Checked = false;
						this.ckbType.Checked = true;
						this.ckbOffSet.Checked = true;
						this.ckbInsideDia.Checked = false;
						return;
					}
				}
				else
				{
					if (!(markStyle == "style2"))
					{
						return;
					}
					this.ckbDiameter.Checked = true;
					this.ckbType.Checked = true;
					this.ckbOffSet.Checked = false;
					this.ckbInsideDia.Checked = false;
					return;
				}
				return;
			}
			if (num <= 2065846456u)
			{
				if (num != 1998588885u)
				{
					if (num != 2065846456u)
					{
						return;
					}
					if (!(markStyle == "style51"))
					{
						return;
					}
					this.ckbDiameter.Checked = false;
					this.ckbType.Checked = false;
					this.ckbOffSet.Checked = false;
					this.ckbInsideDia.Checked = true;
					return;
				}
				else
				{
					if (!(markStyle == "style41"))
					{
						return;
					}
					this.ckbDiameter.Checked = false;
					this.ckbType.Checked = true;
					this.ckbOffSet.Checked = true;
					this.ckbInsideDia.Checked = true;
					return;
				}
			}
			else if (num != 2200214503u)
			{
				if (num != 3944395331u)
				{
					if (num != 4032281248u)
					{
						return;
					}
					if (!(markStyle == "style6"))
					{
						return;
					}
					this.ckbDiameter.Checked = true;
					this.ckbType.Checked = false;
					this.ckbOffSet.Checked = true;
					this.ckbInsideDia.Checked = false;
					return;
				}
				else
				{
					if (!(markStyle == "style61"))
					{
						return;
					}
					this.ckbDiameter.Checked = false;
					this.ckbType.Checked = false;
					this.ckbOffSet.Checked = true;
					this.ckbInsideDia.Checked = true;
					return;
				}
			}
			else
			{
				if (!(markStyle == "style21"))
				{
					return;
				}
				this.ckbDiameter.Checked = false;
				this.ckbType.Checked = true;
				this.ckbOffSet.Checked = false;
				this.ckbInsideDia.Checked = true;
				return;
			}
		}

		private void ckbType_CheckedChanged(object sender, EventArgs e)
		{
			this.SetSelectDiameter();
			if (!this.ckbOffSet.Checked && !this.ckbDiameter.Checked && !this.ckbInsideDia.Checked)
			{
				this.ckbType.Checked = true;
			}
			if (!this.ckbType.Checked && !this.ckbDiameter.Checked && !this.ckbInsideDia.Checked)
			{
				this.ckbOffSet.Checked = true;
			}
			if (!this.ckbOffSet.Checked && !this.ckbType.Checked && !this.ckbInsideDia.Checked)
			{
				this.ckbDiameter.Checked = true;
			}
			if (!this.ckbOffSet.Checked && !this.ckbType.Checked && !this.ckbDiameter.Checked)
			{
				this.ckbInsideDia.Checked = true;
			}
		}

		private void SetSelectDiameter()
		{
			if (this.ckbDiameter.Checked)
			{
				this.ckbInsideDia.Enabled = false;
			}
			else
			{
				this.ckbInsideDia.Enabled = true;
			}
			if (this.ckbInsideDia.Checked)
			{
				this.ckbDiameter.Enabled = false;
				return;
			}
			this.ckbDiameter.Enabled = true;
		}

		private void ckbMoreSelect_CheckedChanged(object sender, EventArgs e)
		{
			if (this.ckbMoreSelect.Checked)
			{
				this.isMarkMultiDisance = true;
				this.hytbMultiSel.Enabled = true;
				return;
			}
			this.isMarkMultiDisance = false;
			this.hytbMultiSel.Enabled = false;
		}

		private void ckbIsDelete_CheckedChanged(object sender, EventArgs e)
		{
			if (this.ckbIsDelete.Checked)
			{
				this.IsDelete = true;
				return;
			}
			this.IsDelete = false;
		}

		public bool IsDelete;

		public string markUpMiddleDown = "";

		public string markContent = "";

		public string markStyle = "";

		public double markDistance;

		public bool isMarkMultiDisance;

		public double markMultiDistance;

		public bool isHaveSlash;

		private System.Drawing.Color color;

		public double pipeTagDis;

		public double multiplyTagDis;

		private HYTagOperate pipeTag;
	}
}
